package com.example.firstapp

import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.widget.Button

class lifecycleActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        Log.d("lifecycleActivity","onCreate")
        setContentView(R.layout.activity_lifecycle)

        val normal:Button = findViewById(R.id.normal)
        normal.setOnClickListener {
            val intent = Intent(this, normalActivity::class.java)
            startActivity(intent)
        }
        val dialog:Button = findViewById(R.id.dialog)
        dialog.setOnClickListener {
            val intent = Intent(this, dialogActivity::class.java)
            startActivity(intent)
        }
    }
    //不可见变为可见
    override fun onStart() {
        super.onStart()
        Log.d("lifecycleActivity","onStart")
    }
    //交互时，一定在栈顶
    override fun onResume() {
        super.onResume()
        Log.d("lifecycleActivity","onResume")
    }
    //暂停 启动或恢复另外一个activity时调用
    override fun onPause() {
        super.onPause()
        Log.d("lifecycleActivity","onPause")
    }
    //完全不可见
    override fun onStop() {
        super.onStop()
        Log.d("lifecycleActivity","onStop")
    }
    // 销毁
    override fun onDestroy() {
        super.onDestroy()
        Log.d("lifecycleActivity","onDestroy")
    }
    // 停止变为调用
    override fun onRestart() {
        super.onRestart()
        Log.d("lifecycleActivity","onRestart")
    }
}